import request from '@/utils/request'

// 创建结伴
export function createAccompany(data) {
  return request({
    url: '/accompany/add',
    method: 'post',
    data
  })
}

// 申请加入结伴
export function joinAccompany(accompanyId) {
  return request({
    url: `/accompany/join/${accompanyId}`,
    method: 'post'
  })
}

// 审核结伴申请
export function auditAccompanyApply(memberId, approved) {
  return request({
    url: `/accompany/audit/${memberId}`,
    method: 'post',
    params: { approved }
  })
}

// 分页查询结伴列表
export function getAccompanyList(pageNum = 1, pageSize = 10) {
  return request({
    url: '/accompany/page',
    method: 'get',
    params: { page: pageNum, size: pageSize }
  })
}

// 查询我参加的结伴
export function getMyJoinedAccompany(pageNum = 1, pageSize = 10) {
  return request({
    url: '/accompany/my-joined',
    method: 'get',
    params: { page: pageNum, size: pageSize }
  })
}

// 查询我发布的结伴
export function getMyCreatedAccompany(pageNum = 1, pageSize = 10) {
  return request({
    url: '/accompany/my-created',
    method: 'get',
    params: { page: pageNum, size: pageSize }
  })
}

// 更新结伴信息
export function updateAccompany(id, data) {
  return request({
    url: `/accompany/${id}`,
    method: 'put',
    data
  })
}

// 删除结伴
export function deleteAccompany(id) {
  return request({
    url: `/accompany/${id}`,
    method: 'delete'
  })
}
// 在 src/api/accompany.js 中添加
export function getAccompanyDetail(id) {
    return request({
      url: `/accompany/getById`,
      method: 'get',
      params: { id }
    })
  }

  // 获取结伴申请记录
export function getAccompanyAuditList(id) {
  return request({
    url: '/accompany/auditList',
    method: 'get',
    params: { id }
  })
}